import 'package:flutter/material.dart';

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, this.title = "Flutter App Page"});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 9, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
          icon: const Icon(Icons.menu),
          onPressed: () {},
        ),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        foregroundColor: Colors.white,
        centerTitle: true,
        title: Text(widget.title),
        actions: [
          IconButton(
            icon: const Icon(Icons.search),
            onPressed: () {},
          ),
          IconButton(
            icon: const Icon(Icons.more_horiz),
            onPressed: () {},
          ),
        ],
        bottom: TabBar(
          controller: _tabController,
          isScrollable: true,
          indicatorColor: Colors.red,
          indicatorWeight: 3,
          indicatorPadding: const EdgeInsets.all(5),
          indicatorSize: TabBarIndicatorSize.tab,
          // indicator: BoxDecoration(
          //   // color: Colors.red,
          //   borderRadius: BorderRadius.circular(10),
          // ),
          labelColor: Colors.red,
          labelStyle: const TextStyle(
            fontSize: 18,
          ),
          unselectedLabelStyle: const TextStyle(
            fontSize: 14,
          ),
          unselectedLabelColor: Colors.white,
          tabs: const [
            Tab(
              child: Text('关注'),
            ),
            Tab(
              child: Text('热门'),
            ),
            Tab(
              child: Text('视频'),
            ),
            Tab(
              child: Text('关注'),
            ),
            Tab(
              child: Text('热门'),
            ),
            Tab(
              child: Text('视频'),
            ),
            Tab(
              child: Text('关注'),
            ),
            Tab(
              child: Text('热门'),
            ),
            Tab(
              child: Text('视频'),
            ),
          ],
        ),
      ),
      body: TabBarView(
        controller: _tabController,
        children: [
          ListView(
            children: const [
              ListTile(
                title: Text("我是关注列表"),
              ),
              ListTile(
                title: Text("我是关注列表"),
              ),
              ListTile(
                title: Text("我是关注列表"),
              ),
            ],
          ),
          ListView(
            children: const [
              ListTile(
                title: Text("我是热门列表"),
              ),
            ],
          ),
          ListView(
            children: const [
              ListTile(
                title: Text("我是视频列表"),
              ),
            ],
          ),
          ListView(
            children: const [
              ListTile(
                title: Text("我是关注列表"),
              ),
              ListTile(
                title: Text("我是关注列表"),
              ),
              ListTile(
                title: Text("我是关注列表"),
              ),
            ],
          ),
          ListView(
            children: const [
              ListTile(
                title: Text("我是热门列表"),
              ),
            ],
          ),
          ListView(
            children: const [
              ListTile(
                title: Text("我是视频列表"),
              ),
            ],
          ),
          ListView(
            children: const [
              ListTile(
                title: Text("我是关注列表"),
              ),
              ListTile(
                title: Text("我是关注列表"),
              ),
              ListTile(
                title: Text("我是关注列表"),
              ),
            ],
          ),
          ListView(
            children: const [
              ListTile(
                title: Text("我是热门列表"),
              ),
            ],
          ),
          ListView(
            children: const [
              ListTile(
                title: Text("我是视频列表"),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
